<?php
/**
 * Created by Veyron
 * User: Vy
 * motto:现在的拼搏 为了更好的明天
 * Class: AdminUser
 * day:  2020/1/15
 * Time: 19:23
 */

namespace app\admin\validate;

use think\Validate;

class AdminUser extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require',
        'captcha'  => 'require|checkCaptcha'
    ];
    protected $message = [
        'username' => '用户名不能为空',
        'password' => '密码不能为空',
        'captcha'  => '验证码不能为空'
    ];

    /**
     * 效验验证码
     * checkCaptcha
     * @param $value
     * @param $rule
     * @param array $data
     * @return \think\response\Json
     */
    protected function checkCaptcha($value,$rule,$data = []){
        if(!captcha_check($value)){
            return '您输入的验证码不正确！';
        }
        return true;
    }
}
